-module(p6).
-export([result/0, main/1]).

result() -> main(100).

main(N) ->
    Seq = lists:seq(1, N),
    square_of_sum(Seq) - sum_of_squares(Seq).

sum_of_squares(Seq) ->
    lists:sum([X * X || X <- Seq]).

square_of_sum(Seq) ->
    Sum = lists:sum(Seq),
    Sum * Sum.
